 <{extends file="<{$tempdir}>/public/wxsite.html"}>  
  <{block name=extendcss}> 
  <link rel="stylesheet"  href="<{$siteurl}>/templates/<{$tempdir}>/public/wxsite/css/weixinlunbo.css">   
 <{/block}>
 
<{block name=hearnav}>
 
<div class="homescreenadd"   onclick="dolink('<{ofunc type=url link="/wxsite/choice"}>');"  ><i class="homescreendw"></i><span  id="showareainfo"><{if $areaid > 0}><{$mapname}><{else}>定位地址信息...<{/if}></span><i class="fa fa-angle-right"></i></div>
<div class="homscrsear"  onclick="dolink('<{ofunc type=url link="/wxsite/search"}>');"   ><input style="    background-position: 3% center;" readonly type="text" placeholder="请输入店铺名、商品名"></div>


<{/block}>
 <{block name=sitetitle}><{$sitename}><{/block}>
 <{block name=blockcontent}> 
	 <div id="wrapper" style="top:73px;">
	 
<div id="scroller">

<!--展示-->
<div class="bannerCon" style="margin-top:0px;">
    <section id="slider" class="swipe" style="visibility: visible;">
  				<div class="swipe-wrap">
  				  <{load_data assign="list" table="adv"    fileds="*"  limit="5" where="advtype='weixinlb' and  module='<{$sitetemp}>' " }> 
  				  <{foreach from=$list['list'] item=items}>
  				   <div class="wrap" ><a href="<{$items['linkurl']}>"><img src="<{$items['img']}>" style="width:100%; height:114px;" alt=""></a></div>
  				  <{/foreach}>
  				</div>
  			 <div class="bgboxgo">
  						<div class="botton-box mBxCm" id="abdcd">
						<{if count($list['list'])  > 1 }>
  							 <{foreach from=$list['list'] item=items}>
  							    <span class="on"></span>
  							 <{/foreach}>
						<{/if}>
  					 </div>
  				</div>
  			</section>
</div>

<!-- 通知 -->
<{load_data assign="notice" table="information"  type="one"  fileds="*"  limit="1" where="type=1"  orderby="orderid asc"  }> 
<{if !empty($notice) }>
<div class="ordisprompt" style="background:#fff;display:none;" >
 <ul>
  <li class="noticeText">通知</li> 
  <li id="gonggaoshow" style="margin-left:5px; float:left;  ">
  <div id="marqueenotice"  onclick="dolink('<{ofunc type=url link="/wxsite/noticelist"}>');"  style="display:none;">
  <marquee align="top" behavior="scroll" scrollamount="4" width="100%"    direction="left"    ><{$notice['title']}></marquee>
  </div>
  <div id="notice"  onclick="dolink('<{ofunc type=url link="/wxsite/noticelist"}>');"  ><{$notice['title']}></div>
  </li>
 </ul>
</div>
<style>
.noticeText{font-size:12px!important;background:url(<{$siteurl}>/templates/<{$tempdir}>/public/wxsite/images/wmr_index_notice.png) 1px 3px no-repeat #ff6e6e;background-size:13px;padding:0px 4px 0px 14px;color:#fff;font-size:12px;}
.ordisprompt ul li {

    float: left;
    color: #fff;
    font-size: 14px;
    line-height: 20px;
	height:20px;
}
</style>
<script>
$(function(){
	$(".ordisprompt").show();
	var getscreenwidth = $(window).width();
	var gongdongWidth = getscreenwidth-67;
	$("#gonggaoshow").css('width',gongdongWidth+'px');
	var gonggaoshow = Number( $("#notice").text().length )*16;
	var screenwidth = document.body.clientWidth-20;
	if( gonggaoshow >= screenwidth ){
  
		$("#marqueenotice").show();
		$("#notice").hide();
	}else{
	 
		$("#marqueenotice").hide();
		$("#notice").show();
	}
});
</script>
<{/if}>


<!--分类部分-->
<div class="categoryContainer">
 <ul>
 <{foreach from=$moretypelist item=items}>
  <li 
	<{if $items['activity'] == 'waimai' }>  
		onclick="dolink('<{ofunc type=url link="/wxsite/waimai/typeid/<{$items['param']}>"}>');"  
	<{else if $items['activity'] == 'market'  }>  
		onclick="dolink('<{ofunc type=url link="/wxsite/marketlist/typeid/<{$items['param']}>"}>');"  
	<{else if $items['activity'] == 'lifehelp'  }>  
		onclick="dolink('<{ofunc type=url link="/wxsite/lifeasslist"}>');"  
	<{/if}>
>
	<a><img src="<{$items['img']}>"  class="category_img"><span><{$items['name']}></span></a>
 </li>
 <{/foreach}>
 
  <li onclick="dolink('<{ofunc type=url link="/wxsite/waimai"}>');"  ><a><img src="<{$siteurl}>/templates/<{$tempdir}>/public/wxsite/images/tb8.png" class="category_img"><span>更多</span></a></li>
 </ul>
</div>
<!--展示-->

 
<!-- 专题页 -->
<div class="advertisement"> 
<{foreach from=$ztylist key=key item=items}>
 <ul class="adver"   style="width:<{$items['imgwidth']}>; height:<{$items['imgheight']}>px; border:none;"  onclick="dolink('<{ofunc type=url link="/wxsite/specialpage/id/<{$items['id']}>"}>');"    >
  <li style="width:100%; height:<{$items['imgheight']}>px;">
  <a href="javascript:void(0);"><img  style="width:100%; height:<{$items['imgheight']}>px;" src="<{$items['indeximg']}>"></a></li>
 </ul>
 <{/foreach}>
 
</div>

<div class="homscrbusinCon">
 <div class="homscrbusintit"><h3>附近商家</h3></div>
 
		<div id="pullDown" style="display:none;">
			<span class="pullDownIcon"></span><span class="pullDownLabel">下拉刷新...</span>
		</div>
		
 <div class="homscrbusinBox">
  <ul   id="supplierlist">
   
 
  </ul>
 </div>
 	 <center>
	<div id="pullUp" style="border-top:0px; ">
			<div style="width:35%; float:left;text-align:right;"><span class="pullUpIcon" style="  margin-left:60%;"></span></div>
			<div style="width:65%; float:left;text-align:left;"><span class="pullUpLabel">上拉加载更多...</span></div>
		</div>
   </center>
   
 
</div>
 
<!---------------------------------------------------------------------------首页结束----------------------------------------------------------------------------------->
 
 

 </div>
</div>
<script>
var can_show = true;
var page = 1;
var catid = <{$typeid|default:0}>;
var order = 0;
var qsjid = 0;
var typeid = <{$typeid|default:0}>;
var myaddress = '<{$myaddress}>';
var search_input = '<{$search_input}>';
var shopshowtype  = '<{$shopshowtype}>';
var checknext = false;
var lat = '<{$lat|default:0}>';
var lng = '<{$lng|default:0}>';
var addressname = '<{$addressname|default:''}>';
var is_loading = false;

$(function(){ 
  
 
  <{if !empty($lng) && !empty($lat) &&  !empty($addressname)  }>
		$('#showareainfo').text(addressname);
		shopdata(); 
   <{else}>   	
		getLocation(); 
   $('#loading').show();
   <{/if}>
  
});
function getLocation()
  {
  	
  if (navigator.geolocation)
    { 
       navigator.geolocation.getCurrentPosition(showPosition,showError);
    }
   else{$('#showareainfo').text("浏览器不支持定位");shopdata();}
  }

function showPosition(position)
{ 

 $.getScript('http://api.map.baidu.com/geocoder/v2/?ak=<{$baidumapkey}>&callback=renderReverse&location='+position.coords.latitude+','+position.coords.longitude+'&output=json&pois=0&coordtype=wgs84ll'); 
  // $.getScript('http://api.map.baidu.com/geocoder/v2/?ak=<{$baidumapkey}>&callback=renderReverse&location=23.036989,114.3679&output=json&pois=0&coordtype=wgs84ll'); 
}
function renderReverse(datas){
 
	 if(datas.status == 0){  
	 
	    $('#showareainfo').text(datas.result.formatted_address); 
		 $.ajax({
           type: 'GET', 
           url: '<{ofunc type=url link="/wxsite/saveloation/datatype/json"}>',
           async:false,
 		  //	data: {'lat':23.036989,'lng':114.3679},
		    data: {'lat':datas.result.location.lat,'lng':datas.result.location.lng,'addressname':datas.result.formatted_address},
           dataType: 'json',success: function(content) { 
          	//var info = JSON.parse(content);
             // $(allobj).eq(i).find('.juliid').eq(0).text(content.msg);  
             if(content.error == false){
                 
             	shopdata();
             }else{
             	  shopdata();// alert(content.msg);
             }
	    	  },
           error: function(content) { 
         
              	shopdata();//alert('提交数据失败');
	        }
       });
		
		
		
		
	 }else{
	   shopdata();
	   $('#showareainfo').text('定位失败');
	 }
 }
  function showError(error)
  {
  	$('#showareainfo').text("定位失败");
   switch(error.code) 
    {
    	
    case error.PERMISSION_DENIED:
      //x.innerHTML="User denied the request for Geolocation."
    //  $('#showareainfo').text("User denied the request for Geolocation.");
      break;
    case error.POSITION_UNAVAILABLE:
     // x.innerHTML="Location information is unavailable."
      //$('#showareainfo').text("Location information is unavailable.");
      break;
    case error.TIMEOUT:
    //  x.innerHTML="The request to get user location timed out."
    //$('#showareainfo').text("The request to get user location timed out.");
      break;
    case error.UNKNOWN_ERROR:
     // x.innerHTML="An unknown error occurred."
     //  $('#showareainfo').text("An unknown error occurred.");
      break;
    }
    
    shopdata();
  }
  function shopdata(){  
			  
			var tempurl = siteurl+'/index.php?ctrl=wxsite&action=indexshoplistdata&page=@page@';
   	 	     tempurl = tempurl.replace('@random@', 1+Math.round(Math.random()*1000)).replace('@page@',page);
	         $.getScript(tempurl); 
  
  }
 function showmoreshop(datas){
  
	var spdatas = eval(datas); 
    if(spdatas.length > 0){
			$("#pullUp").show();
		//var t4em = '';
		for(i=0;i<spdatas.length;i++){
		 	var tempdata = 'red';
				var tempdata2 = '营业中';
					if(spdatas[i].opentype != 2){
					tempdata = '#ccc';
					tempdata2 = '已打烊';
				} 
				if(spdatas[i].opentype ==3){
					tempdata = 'green';
					tempdata2 = '可预订';
				} 
				var backdata = '';
				
				
				
				if(spdatas[i].shoptype == 1  ){   
					backdata +=' <a href="'+siteurl+'/index.php?ctrl=wxsite&action=shopshow&typelx=mk&id='+spdatas[i].id+'">';
				  }else{
				 		backdata += '<a href="'+siteurl+'/index.php?ctrl=wxsite&action=shopshow&typelx=wm&id='+spdatas[i].id+'">';
				  }
				backdata +='  	 <li> ';
				backdata +='  		<div class="homscrbusinimg"><img src="'+spdatas[i].shoplogo+'"></div> ';
				 
				backdata +='  		<div class="listbox"> ';
				backdata +='  		<div class="homscrbusinR"> ';
				backdata +='  		 <div class="homscrbusint" style="height:21px;line-height:21px;"><span style="height:18px;line-height:18px;">'+spdatas[i].shopname+'</span>   '
				if(spdatas[i].opentype != 2  && spdatas[i].opentype != 3    ) {
					backdata += '<span   style="background:#c2c2c2;font-size:12px;font-weight:normal;height:15px;line-height:15px;border-radius:5px;padding:2px 4px;color:#fff;">休息中</span> ';
				}
				backdata +='  	</div> ';
				backdata +='  		 <div class="homscrbusinsale"> ';
				for(j=1;j<=spdatas[i].point;j++){
					backdata += '<i class="fa fa-star"></i>';
				}
				for(q=1;q<=5-spdatas[i].point;q++){
					backdata += '<i class="fa fa-star" style="color:#C7C7C7;"></i>';
				}
				backdata +='  		<span>月售'+spdatas[i].ordercount+'单</span></div> ';
				backdata +='  		 <div class="homscrbusinpric" style="overflow:auto;"><span>起送价￥'+spdatas[i].limitcost+'</span><b>|</b><span>配送费￥'+spdatas[i].pscost+'</span> ';
				if(spdatas[i].attrdet.input != undefined && spdatas[i].attrdet.input != '' ){
					backdata +='  		<b>|</b><span>'+spdatas[i].attrdet.input+'</span>';
				}
				backdata +='  		</div> ';
				backdata +='  		 <div class="homscrbusinadd" >距'+spdatas[i].juli+' &nbsp;'+spdatas[i].address+'</div> ';
				backdata +='  		</div> ';
				backdata +='  		</div> ';
				backdata +='  	</li> ';
				backdata +='  	</a> ';
				
			//	t4em+=backdata;
			$('#supplierlist').append(backdata); 
			 
			
	}
	
	 setTimeout(function () { 
		 is_loading = false;
		 myScroll.refresh();
		// 数据加载完成后，调用界面更新方法 Remember to refresh when contents are loaded (ie: on ajax completion)
	}, 300);
	
				page = Number(page+1);  
        //       $(".mBxCr").hide(); 
              
		}else{
			 setTimeout(function () { 
		 is_loading = false;
		 
		// 数据加载完成后，调用界面更新方法 Remember to refresh when contents are loaded (ie: on ajax completion)
	}, 300);
				can_show =  false; 
      		      if(page == 1){ 
      		      	 error($('#supplierlist'),'很遗憾,附近商家正在覆盖中...');
					$("#pullUp").hide();					 
      		 
      		      }else{ 
      		        $('.pullUpLabel').text('更多商家,敬请期待中...'); 
      		      }
      		   myScroll.refresh();
			   
		
		}
		
		
	 
    	
 }
  
</script>
 
 </script>
<{/block}>
<{block name=myScrolljs}>

<script>
		var myScroll, pullDownEl, pullDownOffset,pulldowncate,
	pullUpEl, pullUpOffset,
	generatedCount = 0;
	
	

function pullDownAction () {
	 
}

function pullUpAction () {
  if(is_loading == false){
       is_loading = true;
		setTimeout(function () { 
		shopdata();
	    
		 
		// 数据加载完成后，调用界面更新方法 Remember to refresh when contents are loaded (ie: on ajax completion)
	}, 400);	// <-- Simulate network congestion, remove setTimeout from production!
	}
	 
}

function loaded() {
	pullDownEl = document.getElementById('pullDown');
	pullDownOffset = pullDownEl.offsetHeight;
	pullUpEl = document.getElementById('pullUp');	
	pullUpOffset = pullUpEl.offsetHeight;
	
	myScroll = new iScroll('wrapper', {
		scrollbarClass: 'myScrollbar', /* 重要样式 */
		useTransition: false, /* 此属性不知用意，本人从true改为false */
		topOffset: pullDownOffset,
		onRefresh: function () {
		 
			if (pullDownEl.className.match('loading')) {
				pullDownEl.className = '';
				pullDownEl.querySelector('.pullDownLabel').innerHTML = '下拉刷新...';
			} else if (pullUpEl.className.match('loading')) {
				pullUpEl.className = '';
				pullUpEl.querySelector('.pullUpLabel').innerHTML = '上拉加载更多...';
			}
			 
		},
		onScrollMove: function () { 
	 
			if (this.y > 1 && !pullDownEl.className.match('flip')) {
				
				pullDownEl.className = 'flip';
				pullDownEl.querySelector('.pullDownLabel').innerHTML = '松手开始更新...';
				this.minScrollY = 0;
			} else if (this.y < 1 && pullDownEl.className.match('flip')) {
				pullDownEl.className = '';
				pullDownEl.querySelector('.pullDownLabel').innerHTML = '下拉刷新...';
				this.minScrollY = -pullDownOffset;
			} else if (this.y < (this.maxScrollY - 50) && !pullUpEl.className.match('flip')) {
				pullUpEl.className = 'flip';
				pullUpEl.querySelector('.pullUpLabel').innerHTML = '松手开始更新...';
				this.maxScrollY = this.maxScrollY;
			} else if (this.y > (this.maxScrollY + 1) && pullUpEl.className.match('flip')) {
		
				pullUpEl.className = '';
				pullUpEl.querySelector('.pullUpLabel').innerHTML = '上拉加载更多...';
				this.maxScrollY = pullUpOffset;
			}
			 
		},
		onScrollEnd: function () {
			if (pullUpEl.className.match('flip')) {
				if (this.y < (this.maxScrollY + 50)){
						 
						pullUpEl.className = 'loading';
						pullUpEl.querySelector('.pullUpLabel').innerHTML = '加载中...';				
						pullUpAction();	
				}
			}
		 
		
			 
		}
	});
	
	setTimeout(function () { document.getElementById('wrapper').style.left = '0'; }, 200);
}

//初始化绑定iScroll控件 
document.addEventListener('touchmove', function (e) { e.preventDefault(); }, false);
document.addEventListener('DOMContentLoaded', loaded, false); 


</script>
 <script>
 
 	$(function(){ 
		 
 	      var bullets = document.getElementById('abdcd').getElementsByTagName('span');
 	      var slider =  Swipe(document.getElementById('slider'), {
           auto: 3000,
           continuous: true,
           callback: function(pos) { 
              var i = bullets.length;
              while (i--) {
                bullets[i].className = ' ';
              }
              bullets[pos].className = 'on'; 
           }
        });  
});  
</script>

<{/block}>